<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>全局过滤器</title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="box">
			<span>{{date | nowdate}}</span>
		</div>
		<script type="text/javascript">
			Vue.filter('nowdate',function(value){
				var year = value.getFullYear();
				var month = value.getMonth()+1;
				var dates = value.getDate();
				var day = value.getDay();
				var week = "";
				for(var i=0;i<7;i++){
					if(i=day){
						return "星期"+i;
					}
				}

				switch(day){
					case 1:
					week="星期一";
					break;
					case 2:
					week="星期二";
					break;
					case 3:
					week="星期三";
					break;
					case 4:
					week="星期四";
					break;
					case 5:
					week="星期五";
					break;
					case 6:
					week="星期六";
					break;
					default:
					week="星期天";
					break;
				}
				return "今天是"+year+"年"+month+"月"+dates+"日"+week;
			});
			
			new Vue(
				{
					el:'#box',
					data:{
						date:new Date()
					}
				}
			);
		</script>
	</body>
</html>
